package com.jingtai.shop.webfacade.bo.shopcar;

import cn.hutool.core.util.ObjectUtil;
import com.jingtai.common.webfacade.BaseBO;
import com.jingtai.common.webfacade.error.CommonException;
import com.jingtai.common.webfacade.error.ErrorEnum;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;

import java.math.BigDecimal;

/**
 * 下单-商品信息
 */
@Data
public class SubmitOrderDetailBO extends BaseBO {
    /**
     * 运费
     */
    private BigDecimal freight;

    /**
     * 优惠价
     */
    private BigDecimal preferentialPrice;

    /**
     * 用户实付价格
     */
    private BigDecimal memberRealPay;

    /**
     * 商品单价
     */
    private BigDecimal goodsUnitPrice;

    /**
     * 商品编码
     */
    private String goodsCode;

    /**
     * sku编码-商品属性
     */
    private String skuCode;

    /**
     * 商品数量
     */
    private Integer goodsNumber;




    @Override
    public void validate() {
        super.validate();

        if (ObjectUtil.isEmpty(freight) || ObjectUtil.isEmpty(preferentialPrice)
                || ObjectUtil.isEmpty(memberRealPay)
                || StringUtils.isBlank(goodsCode)
                || StringUtils.isBlank(skuCode)
                || ObjectUtil.isEmpty(goodsNumber)
                || ObjectUtil.isEmpty(goodsUnitPrice)) {
            throw new CommonException(ErrorEnum.REQUIRED_PARAM_EMPTY);
        }
    }
}
